﻿/*
 * @author: wizardc
 */

using System;

namespace Dou.UI
{
    /// <summary>
    /// 数组数据源
    /// </summary>
    public class ArrayCollection<T> : ICollection
    {
        private T[] _source;
        
        public ArrayCollection(T[] source)
        {
            _source = source;
        }

        public T[] source
        {
            set => _source = value;
            get => _source;
        }
        
        public int count => _source.Length;
        
        public object GetItemAt(int index)
        {
            return _source[index];
        }

        public int GetItemIndex(object item)
        {
            return Array.IndexOf(_source, (T) item);
        }
    }
}
